(function () {

    angular.module('cf-content').directive('navbar', ['$timeout', "$window", function ($timeout, $window, EVENT) {
            return {
                restrict: 'AE',
                templateUrl: 'app/navbar/navbar.html',
                replace: true,
                controller: navbarCtroller,
                controllerAs: 'navbar'
            }
        }])


    navbarCtroller.$inject = ['$scope', 'Api', '$state', 'assetUrl'];

    function navbarCtroller($scope, API, $state, assetUrl) {
        var vm = this;

        vm.logo = assetUrl + 'assets/images/logo-pic.png';

        vm.Logout = function logout() {
            API.Login.Out().$promise.then(function (data) {
                $state.go('login');
            })
        }
        $scope.$on('$stateChangeSuccess', function () {
            if ($state.current.name === "login") {
                vm.login = false;
            }else{
                vm.login = true;
            }
        });
    }

})();

